<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
    <script src="../vue.js"></script>
    <script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/qs/6.10.1/qs.js"></script>
</head>

<body>
    <div id="app">
        token: {{ info }}
        userInfo:{{userInfo}}

    </div>
    <script >

        const params = new URLSearchParams();
        params.append('userName','skyme')
        params.append('passWord','w5103265')
        let qs = Qs;


        config1 = {
            method: 'post',
            url: 'http://127.0.0.1:8084/admin/login',
            headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
           },
           
            data: qs.stringify({
                userName:'test',
                passWord:'123456'
            })

        };
        function createConfig2(token) {
            return {
                method: 'get',
                url: 'http://127.0.0.1:8084/user/userInfo',
                data: {},
                params: {},
                headers: { "token": token }
            };
        }
        let vm = new Vue({
            el: '#app',
            data() {
                return {
                    info: null,
                    userInfo:null
                }
            },
            mounted() {
                axios(config1)
                    .then(function (response) {
                        console.log(response)
                        vm.info = response.data.data.token;
                        console.log(vm.info)
                        return createConfig2(vm.info);
                    }).catch(function (error) { // 请求失败处理
                 console.log("error"+error);})
    .then(function (config2) {
                        return axios(config2); // 发送第二个请求
                    }).catch(function (error) { // 请求失败处理
                 console.log("error"+error);}).then(function (response) {
                       vm.userInfo = response.data.data;
                    })
            }
        })
    </script>
</body>

</html>